import { defineStore } from "pinia"
import hyRequest from "@/services/request"

// http://123.207.32.32:1888/api/home/hotSuggests
// http://codercba.com:1888/api/home/houselist?page=1
const useHomeStore = defineStore("home",{
    state:() =>({
        hotSuggests:[],
        houseList:[],
        currentPage:1
    }),
    actions:{
        async fetchHotSuggestsAction() {
            const res = await hyRequest.get("/home/hotSuggests")
            this.hotSuggests = res.data.data
        }, 
        async fetchHouseListAction() {
            const res = await hyRequest.get("/home/houselist",{
                page:this.currentPage++
            })
            this.houseList.push(...res.data.data)
        }
    }
})

export default useHomeStore